// import type { ResultSystemFileDuiXiang, SystemFileDuiXiang } from '@/genapi/base';
// import { planFilingsSystemSystemFileUploadbyPost } from '@/genapi/base';

import type { components } from "@/genapi/wh";
import { enclosureSysFileUploadImageUsingPost } from "@/genapi/wh-xtd";
import { jeecgBootDevFileUploadLocalReturnUrlUsingPost } from "@/genapi/system";

/**
 * 上传接口
 * @param options
 */
export function uploadRequest(
	file: Blob,
	type?: string,
	onUploadProgress?: (data: any) => void,
): Promise<components["schemas"]["ResultSystemFileDuiXiang"]> {
  console.log(file)
	// const data: any = new FormData();
	// data.append("file", file);
	// data.append("type", type);
  // console.log(data)
  // const data = file
	return jeecgBootDevFileUploadLocalReturnUrlUsingPost({
		data:file,
		params: {
      bizFileType:type
    },
    // header:{
    //   "Content-Type": "multipart/form-data" 
    // }
	});
}

/**
 * 通过资源对象格式化成URL
 *
 * @param options 资源对象
 * @param sign 	连接有效签名，登录时可忽略
 */
export function formatFilePath(
	options?: components["schemas"]["SystemFileDuiXiang"] | string,
) {
	let path: string | undefined;
	if (typeof options === "string" || typeof options === "number") {
		path = `${options}`;
	} else if (options?.path) {
		path = options.path;
	}
	if (path) {
		return `${import.meta.env.VITE_SERVER_URL}${path}`;
	}
}
